# Chunking

import json
def chunking(data_path:str)->list[str]:
    with open(data_path,"r",encoding="utf-8") as file:
        data = json.load(file)
 
    chunks = [f"标题：“{item['title']}”；发布时间：“{item['time']}”；链接：“{item['link']}”；内容预览：“{item['preview']}”\n" for item in data]
    return chunks

if __name__ == "__main__":
    chunks = chunking("./data/data.json")
    with open('./data.txt',"w+",encoding="utf-8") as file:
        for chunk in chunks:
            file.writelines(chunk)